package com.zlx.guguanjia.mapper.provider;

import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @Author 周罗校
 * @Description
 * @ClassName SysLogSqlProvider
 * @date 2020.11.09 17:04:48
 * 该版权归周罗校所有，最终解释权以官方为准
 */
public class SysLogSqlProvider {
    public String selectPage(Map<String,Object> condition){
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT " +
                "sys_log.id, " +
                "sys_log.type, " +
                "sys_log.create_by, " +
                "sys_log.create_date, " +
                "sys_log.remote_addr, " +
                "sys_log.user_agent, " +
                "sys_log.request_uri, " +
                "sys_log.method, " +
                "sys_log.params, " +
                "sys_log.exception, " +
                "sys_log.description " +
                "FROM " +
                "sys_log " +
                "WHERE 1=1 ");
        if (condition.containsKey("description")&&!StringUtils.isEmpty(condition.get("description"))){
            sb.append("And description like CONCAT('%',#{description},'%') ");
        }
        if (condition.containsKey("type")&&!StringUtils.isEmpty(condition.get("type"))){
            sb.append("And type = #{type}");
        }
        return sb.toString();
    }
}
